﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>WinGetPos - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The WinGetPos function retrieves the position and size of the specified window." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>WinGetPos</h1>

<p>Retrieves the position and size of the specified window.</p>

<pre class="Syntax"><span class="func">WinGetPos</span> <span class="optional">X, Y, Width, Height, WinTitle, WinText, ExcludeTitle, ExcludeText</span></pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>X, Y</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#variables">变量</a></p>
    <p>The names of the variables in which to store the X and Y coordinates of the  target window's upper left corner. If omitted, the corresponding values will not be stored.</p>
  </dd>

  <dt>Width, Height</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#variables">变量</a></p>
    <p>The names of the variables in which to store the width and height of the target window. If omitted, the corresponding values will not be stored.</p>
  </dd>

  <dt>WinTitle</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a>, <a href="../Concepts.htm#numbers">整数</a>或<a href="../Objects.htm">对象</a></p>
    <p>识别目标窗口的窗口标题或其他条件. 请参阅 <a href="../misc/WinTitle.htm">WinTitle</a>.</p>
  </dd>

  <dt>WinText</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>如果存在, 此参数必须是目标窗口的单个文本元素的子字符串(和内置的 Window Spy 工具显示的一样). 如果 <a href="DetectHiddenText.htm">DetectHiddenText</a> 为 ON, 那么会检测隐藏文本元素.</p>
  </dd>

  <dt>ExcludeTitle</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>标题中含有此参数值的窗口将被排除.</p>
  </dd>

  <dt>ExcludeText</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>文本中含有此参数值的窗口将被排除.</p>
  </dd>

</dl>

<h2 id="Remarks">备注</h2>
<p>If no matching window is found, the output variables will be made blank.</p>
<p>If the <em>WinTitle</em> &quot;Program Manager&quot; is used, the function will retrieve the size of the desktop, which is usually the same as the current screen resolution.</p>
<p>A minimized window will still have a position and size. The values returned in this case may vary depending on OS and configuration.</p>
<p>To discover the name of the window and control that the mouse is currently hovering over, use <a href="MouseGetPos.htm">MouseGetPos</a>.</p>
<p>窗口标题和文本是区分大小写的. 除非 <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> 被打开, 否则不会检测隐藏窗口.</p>
<p>As the coordinates returned by this function include the window's title bar, menu and borders, they may be dependent on OS version and theme. To get more consistent values across different systems, consider using <a href="WinGetClientPos.htm">WinGetClientPos</a> instead.</p>

<h2 id="Related">相关</h2>
<p><a href="WinMove.htm">WinMove</a>, <a href="WinGetClientPos.htm">WinGetClientPos</a>, <a href="ControlGetPos.htm">ControlGetPos</a>, <a href="WinGetTitle.htm">WinGetTitle</a>, <a href="WinGetText.htm">WinGetText</a>, <a href="ControlGetText.htm">ControlGetText</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>WinGetPos X, Y, Width, Height, "Calculator"
MsgBox "Calculator is at " X "," Y

WinGetPos X, Y,,, "A"  <em>; &quot;A&quot; to get the active window's pos.</em>
MsgBox "The active window is at " X "," Y

if WinExist("Untitled - Notepad")
{
    WinGetPos Xpos, Ypos  <em>; Uses the window found above.</em>
    MsgBox "Notepad is at " Xpos "," Ypos
}</pre>
</div>

</body>
</html>